import java.util.Scanner;

public class Person {
    private final Board board;

    public Person(Board board) {
        this.board = board;
    }

    public void playChess() {
        int i = 1;
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("请输入落子坐标：");
            int x = scanner.nextInt();
            int y = scanner.nextInt();

            if (x < 0 || x >= 15 || y < 0 || y >= 15) {
                System.out.println("坐标越界，请重新输入。\n");
                continue;
            }

            char chess = (i % 2 == 1) ? '●' : '○';
            if (board.board[x][y] == '+') {
                board.board[x][y] = chess;
            } else {
                System.out.println("该位置已经有棋子了，请重新输入。\n");
                continue;
            }
            board.printBoard();
            if (board.checkWin(chess)) {
                System.out.println(chess + " 获胜！");
                break;
            }

            i++;
        }
    }
}
